<template>
	<el-container>
		<el-header>
			<div class="left-panel">
				<!-- <el-button type="primary" icon="el-icon-plus" @click="add"></el-button> -->
				<el-button type="primary" icon="sc-icon-download" @click="onBatchExport">导出</el-button>
				<div class="right-panel-search" style="margin-left: 10px;">
					<el-date-picker style="width: 150px;" v-model="search.start_time" value-format="X" type="date"
						placeholder="开始时间" />
					<el-date-picker style="width: 150px;" v-model="search.end_time" value-format="X" type="date"
						placeholder="截止时间" />
					<el-select style="width: 100px;" v-if="types" v-model="search.type" clearable
						placeholder="状态" filterable>
						<el-option v-for="(item, key) in types" :key="key" :label="item" :value="key" />
					</el-select>
					<el-input style="width: 100px;" v-model="search.member_id" placeholder="会员ID" clearable></el-input>
					<el-input style="width: 150px;" v-model="search.real_name" placeholder="收款人姓名" clearable></el-input>
					<el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
				</div>
			</div>
			<div class="right-panel">
				<!-- <div class="right-panel-search">
					<el-date-picker style="width: 150px;" v-model="search.start_time" value-format="X" type="date"
						placeholder="开始时间" />
					<el-date-picker style="width: 150px;" v-model="search.end_time" value-format="X" type="date"
						placeholder="截止时间" />
					<el-select style="width: 100px;" v-if="types" v-model="search.type" clearable
						placeholder="状态" filterable>
						<el-option v-for="(item, key) in types" :key="key" :label="item" :value="key" />
					</el-select>
					<el-input style="width: 100px;" v-model="search.member_id" placeholder="会员ID" clearable></el-input>
					<el-input style="width: 150px;" v-model="search.real_name" placeholder="收款人姓名" clearable></el-input>
					<el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
				</div> -->
			</div>
		</el-header>
		<el-main class="nopadding">
			<scTable ref="table" :apiObj="list.apiObj" row-key="id" stripe>
				<el-table-column label="会员ID" prop="member_id" width="150"></el-table-column>
				<el-table-column label="订单号" prop="ordernum" width="150"></el-table-column>
				<el-table-column label="收款信息" width="180">
					<template #default="scope">
						<p>银行：{{scope.row.bankname}}</p>
						<p>收款人：{{scope.row.real_name}}</p>
						<p>收款账号：{{scope.row.bank_account}}</p>
					</template>
				</el-table-column>
				<el-table-column label="金额" prop="amount" width="100"></el-table-column>
				<el-table-column label="备注" prop="remark" width="150"></el-table-column>
				<el-table-column label="第三方单号" prop="tordernum" width="150"></el-table-column>
				<el-table-column label="状态" prop="status" width="80">
					<template #default="scope">
						<p>{{statuss[scope.row.status]}}</p>
					</template>
				</el-table-column>
				<el-table-column label="创建时间" prop="create_time" width="150"></el-table-column>
				<el-table-column label="手机号" prop="phone" width="150"></el-table-column>
				<el-table-column label="当前余额" prop="balance" width="150"></el-table-column>
				<el-table-column label="操作" fixed="right" align="right" width="150">
					<template #default="scope">
						<el-button plain size="small" v-if="scope.row.status == 0" @click="table_ReviewWithdrawal(scope.row)">提现审核</el-button>
					</template>
				</el-table-column>
			</scTable>
		</el-main>
	</el-container>

	<review-withdrawal-dialog v-if="dialog.ReviewWithdrawal" ref="ReviewWithdrawalDialog" @success="handleSaveSuccess" @closed="dialog.ReviewWithdrawal=false"></review-withdrawal-dialog>

</template>

<script>
	import ReviewWithdrawalDialog from './ReviewWithdrawal'
	// import table2excel from 'js-table2excel'
	import config from "@/config/table";
	export default {
		name: 'configureList',
		components: {
			ReviewWithdrawalDialog,
		},
		data() {
			return {
				search: {
					real_name: '',
					member_id: '',
					status: '',
					start_time: '',
					end_time: ''
				},
				dialog:{
					ReviewWithdrawal: false,
				},
				list: {
					apiObj: this.$API.fund.fund.list
				},
				statuss: {'0': '待审核', '1': '已审核', '2': '已打款', '3': '驳回'},
			}
		},
		mounted() {

		},
		methods: {
			//退款审核
			table_ReviewWithdrawal(row){
				this.dialog.ReviewWithdrawal = true
				this.$nextTick(() => {
					this.$refs.ReviewWithdrawalDialog.open().setData(row)
				})
			},
			async onBatchExport () {
			 var reqData = {
			 	[config.request.page]: this.$refs.table.currentPage,
			 	[config.request.pageSize]: this.$refs.table.scPageSize,
			 	[config.request.prop]: this.$refs.table.prop,
			 	[config.request.order]: this.$refs.table.order
			 }
			 let search = JSON.parse(JSON.stringify(this.search))
			 var res = await this.$API.fund.fund.list.get({...reqData, ...this.$refs.table.tableParams, ...search, is_export: 1});
			 if (res.code == 200) {
			 	window.open(res.data.url, '_blank')
			 } else {
			 	this.$alert(res.msg, "提示", {
			 		type: 'error'
			 	})
			 }
			},
			//搜索
			upsearch() {
				// console.log(112, this.search)
				let search = JSON.parse(JSON.stringify(this.search))
				this.$refs.table.upData({
					...search
				})
			},

			//本地更新数据
			handleSaveSuccess(data, mode){
				//为了减少网络请求，直接变更表格内存数据
				if(mode=='add'){
					// this.$refs.table.unshiftRow(data)
				}else if(mode=='edit'){
					// this.$refs.table.updateKey(data)
				}

				//当然也可以暴力的直接刷新表格
				this.$refs.table.refresh()
			}
		}
	}
</script>

<style>
</style>
